package br.pucrio.inf.aaaong.interceptors;

import br.com.caelum.vraptor.InterceptionException;
import br.com.caelum.vraptor.Intercepts;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.core.InterceptorStack;
import br.com.caelum.vraptor.interceptor.Interceptor;
import br.com.caelum.vraptor.ioc.RequestScoped;
import br.com.caelum.vraptor.resource.ResourceMethod;
import br.pucrio.inf.aaaong.models.authentication.LoginSession;

@RequestScoped
@Intercepts
public class AssistenteLoggedInterceptor implements Interceptor {

	private LoginSession session;
	private Result result;

	public AssistenteLoggedInterceptor(LoginSession session, Result result) {
		this.session = session;
		this.result = result;
	}
	
	@Override
	public boolean accepts(ResourceMethod action) {
		return true;
	}

	@Override
	public void intercept(InterceptorStack stack, ResourceMethod method,
			Object resource) throws InterceptionException {
		result.include("loggedAssistente", session.getAssistente());
		 stack.next(method, resource);
	}
}
